import request from '@/utils/request'
import axios from 'axios'

export function listorderCalculationResults(query) {
  return request({
    url: '/orderCalculationResults/list',
    method: 'get',
    params: query
  })
}

export function deleteorderCalculationResults(data) {
  return request({
    url: '/orderCalculationResults/delete',
    method: 'post',
    data
  })
}

export function uploadExcels(data) {

  return request({
    url: '/orderCalculationResults/uploadExcels',
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    data
  })
}
export function downloadExcels(data) {
  return request({
    url: '/orderCalculationResults/downloadExcel',
    method: 'get',
    data
  })
}


export const uploadFileRequest = (url, params) => {
  return axios({
    method: 'post',
    url: '/orderCalculationResults/insertMany',
    data: params,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

export function publishorderCalculationResults(data) {
  return request({
    url: '/orderCalculationResults/create',
    method: 'post',
    data
  })
}

export function insertAllorderCalculationResults(data) {
  return request({
    url: '/orderCalculationResults/insertMany',
    method: 'post',
    data
  })
}

export function detailorderCalculationResults(id) {
  return request({
    url: '/orderCalculationResults/detail',
    method: 'get',
    params: { id }
  })
}

export function editorderCalculationResults(data) {
  return request({
    url: '/orderCalculationResults/update',
    method: 'post',
    data
  })
}
export function moreorderCalculationResults(data) {
  return request({
    url: '/orderCalculationResults/more',
    method: 'post',
    data
  })
}

export function listCatAndBrand() {
  return request({
    url: '/orderCalculationResults/catAndBrand',
    method: 'get'
  })
}

export function myformatdate(inputTime) {
  if (!inputTime && typeof inputTime !== 'number') {
    return ''
  }
  var localTime = ''
  inputTime = new Date(inputTime).getTime()
  const offset = (new Date()).getTimezoneOffset()
  localTime = (new Date(inputTime - offset * 60000)).toISOString()
  localTime = localTime.substr(0, localTime.lastIndexOf('.'))
  localTime = localTime.replace('T', ' ')
  return localTime
}
export function formatterTime(row, column) {
  const data = row[column.property]
  return /\d{4}-\d{1,2}-\d{1,2}/g.exec(data)
}

export function uploadFile(data) {
  return request({
    method: 'post',
    url: '/orderCalculationResults/insertMany',
    data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}
